﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _07IsItPrime
{
    class _07IsItPrime
    {
        static void Main(string[] args)
        {
            //This is a slight modification of the IsPrime demo from lecture 6.
            Console.WriteLine("Enter a positive integer number betweeen 1 and 100: ");
            int number = int.Parse(Console.ReadLine());
            if (number < 2)
            {
                Console.WriteLine("Invalid number, must be greater than 1");
                return;
            }
            if (number > 100)
            {
                Console.WriteLine("Invalid number, must be less than 100.");
                return;
            }            
            uint divider = 2;
            uint maxDivider = (uint)Math.Sqrt(number);
            bool prime = true;
            while (prime && (divider <= maxDivider))
            {
                if (number % divider == 0)
                {
                    prime = false;
                }
                divider++;
            }
            Console.WriteLine("Prime? {0}", prime);
        }
    }
}
